package com.bw.util;

import java.sql.*;
import java.util.ResourceBundle;

/***************************
 FileAction:

 CreateTime:2022-04-11 8:20
 Author:Aaking-aline
 ****************************/
public class JDBC {
    private static ResourceBundle rb = ResourceBundle.getBundle("database");
    private static String driver = rb.getString("driver");
    private static String url = rb.getString("url");
    private static String user = rb.getString("user");
    private static String pass = rb.getString("pass");

    static {
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection(url, user, pass);
    }


    public static void close(ResultSet rs, PreparedStatement ps,Connection co) throws SQLException {
        rs.close();
        ps.close();
        co.close();
    }

    public static void close(PreparedStatement ps,Connection co) throws SQLException {
        ps.close();
        co.close();
    }

}
